{% extends "model/adminbase.html" %}
{% block title %} 添加图书 {% endblock %}
{% block StyleSheet %}
    <link rel="stylesheet" href="/static/plugins/daterangepicker/daterangepicker.css">
{% endblock %}
{% block script %}
    <script src="/static/plugins/daterangepicker/daterangepicker.js"></script>
    <script>
        $(function () {
            // 初始化 select组件样式
            $('.select2').select2()
              $('#reservation').daterangepicker({locale:
                      {applyLabel: '确定',cancelLabel: '取消',customRangeLabel: '自定义范围',
                      format:'YYYY-MM-DD',

                      },
                singleDatePicker: true,
                })
            $('.select2bs4').select2({
              theme: 'bootstrap4'
            })

            // 修改成功
            if("{{ work }}" === "work"){
             setTimeout(function () {
                    alert("图书入库成功");
             },200)
         }
        })
    </script>
{% endblock %}

{% block content %}
    <form action="/add_book/" method="POST">

    {% csrf_token %}
      <!-- Input addon -->
            <div class="card card-info " style="margin-top: -20px">
              <div class="card-header  gradient-color-her">
                <h3 class="font-weight-light" style="color: #0b2e13">添加图书</h3>
              </div>
              <div class="card-body">

                  <div class="row"> <!--排版整个表单的row-->
                      <div class="col-sm-5 offset-lg-1"><!--左侧一列-->

                          <div class="form-group">
                           <label for="{{ form.BName.id_for_label }}">书名</label>
                          {{ form.BName }}
                          <span id="terms-error" class="error invalid-feedback" style="display: inline;">{{ form.BName.errors }}</span>
                        </div>

                          <div class="form-group">
                           <label for="{{ form.Author.id_for_label }}">作者</label>
                          {{ form.Author }}
                          <span id="terms-error" class="error invalid-feedback" style="display: inline;">{{ form.Author.errors }}</span>
                        </div>
                          <div class="form-group">
                               <label for="{{ form.Publisher.id_for_label }}">出版社</label>
                                {{ form.Publisher }}
                              <span id="terms-error" class="error invalid-feedback" style="display: inline;">{{ form.Publisher.errors }}</span>
                          </div>
                          <div class="form-group">
                              <label for="{{ form.NumInLib.id_for_label }}">入库数量:</label>
                              {{ form.NumInLib }}
                              <span id="terms-error" class="error invalid-feedback" style="display: inline;">{{ form.NumInLib.errors }}</span>


                          </div>
                              <!-- /.input group -->

                        </div>

                      <div class="col-sm-5"><!--右侧一列-->

                      <div class="form-group">
                           <label for="{{ form.Price.id_for_label }}">价格</label>
                                {{ form.Price }}
                          <span id="terms-error" class="error invalid-feedback" style="display: inline;">{{ form.Price.errors }}</span>
                      </div>

                          <div class="form-group">
                           <label for="{{ form.Name.id_for_label }}">出版时间</label>

                              <div class="input-group-prepend" >
                             <span class="input-group-text">
                                <i class="far fa-calendar-alt"></i>
                              </span>
                                  {{ form.PubTime }}
                            </div>
                          <span id="terms-error" class="error invalid-feedback" style="display: inline;">{{ form.PubTime.errors }}</span>
                        </div>
                           <div class="form-group">
                           <label for="{{ form.Category.id_for_label }}">类别</label>
                          {{ form.Category }}
                          <span id="terms-error" class="error invalid-feedback" style="display: inline;">{{ form.Category.errors }}</span>
                        </div>

                      </div>
                  </div>
                  <div class="row">
                      <div class="col-sm-10 offset-sm-1">
                          <div class="form-group">
                           <label for="{{ form.Content.id_for_label }}">图书简介</label>
                          {{ form.Content }}
                          <span id="terms-error" class="error invalid-feedback" style="display: inline;">{{ form.Content.errors }}</span>
                        </div>
                      </div>
                  </div>
                  <!--提交按钮-->
                <div class="card-footer row " style="background-color: white">
                  <button type="submit" id="pwd-smt"  class="btn btn-primary  offset-lg-1 pwd-smt-bnt">添加图书</button>
                </div>
              </div>
              <!-- /.card-body -->
            </div>
            <!-- /.card -->
     </form>
{% endblock %}
